package com.cssl.config;

import com.cssl.domain.AliOssProperties;
import com.cssl.util.FileUpload;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FileUploadConfig {
    @Bean
    // 确保只会有一个Bean
    @ConditionalOnMissingBean
    public FileUpload aliOssUtil(AliOssProperties aliOssProperties) {
        System.out.println("aliOssProperties = " + aliOssProperties);
        return new FileUpload(aliOssProperties.getEndpoint(), aliOssProperties.getAccessKeyId() ,aliOssProperties.getAccessKeySecret(), aliOssProperties.getBucketName());
    }
}
